package com.dd.cloud.user.feign;

import com.dd.cloud.auth.entity.AdminRole;
import com.dd.cloud.auth.entity.RoleMenu;
import com.dd.cloud.auth.req.role.UserBindRoleReq;
import com.dd.cloud.auth.res.UserToRoleRes;
import com.dd.cloud.common.vo.LoginInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @Description: auth服务远程
 * @Author: czg
 * @Date: 2023/06/02 17:41
 * @Version: 1.0.0
 */
@FeignClient("dd-auth-service")
public interface AuthFeignService {

    /**
     * 用户类型查询权限id
     */
    @PostMapping("/auth/power/roleId/by/userId")
    ResponseEntity<AdminRole> roleIdByUserId(@RequestBody LoginInfo loginInfo);

    /**
     * 查询用户是否超管
     */
    @GetMapping("/auth/power/user/isAdmin")
    ResponseEntity<Integer> userIsAdmin(@RequestParam Integer userId, @RequestParam Integer userType);

    /**
     * 用户绑定角色
     */
    @PostMapping("/auth/power/user/bind/role")
    ResponseEntity<Integer> userBindRole(@RequestBody UserBindRoleReq req);

    @GetMapping("/auth/power/menu/tree/roleId")
    ResponseEntity<List<RoleMenu>> queryMenuTreeByRoleId( @RequestParam Integer roleId);

    /**
     * 查询所有用户的权限内容
     */
    @GetMapping("/auth/power/user/role/list")
    ResponseEntity<List<UserToRoleRes>> userRoleList();

    /**
     * 查询用户角色信息
     */
    @GetMapping("/auth/power/user/role/info")
    public ResponseEntity<AdminRole> queryRoleByUserId(@RequestParam(name = "userId") Integer userId,
                                                       @RequestParam(name = "type") Integer type);
}
